//
//  UIImageView+extension.swift
//  daoge_sineweibo
//
//  Created by 伍禄林 on 16/10/15.
//  Copyright © 2016年 伍禄林. All rights reserved.
//

import SDWebImage


extension UIImageView {
    
    /// 隔离SDWebImage
    ///
    /// - parameter urlString:        url
    /// - parameter placeholderImage: 占位图片
    func cz_setImage(urlString: String?, placeholderImage: UIImage?, isAvater: Bool =  false)  {
        
        
        guard let urlString = urlString,
            let url = URL(string: urlString) else {
            
            image = placeholderImage
            return
        }
        
        sd_setImage(with: url, placeholderImage: placeholderImage, options: []) {[weak self]
            (webImage, _, _, _) in
            
            if isAvater {
                 self?.image = webImage?.cz_avaterImage(size: (self?.bounds.size)!)
            }
           
        }
        
    }
    
}
